package com.sophialex.health.record.lktable.cellstyle;

import java.util.Iterator;
import java.util.Set;

import com.sophia.dict.vo.DictCode;
import com.sophialex.health.common.platform.SuperContext;
import com.sophialex.health.record.common.utils.CommonUtils;
import com.sophialex.health.system.frame.widgets.dbTable.IGetJoinOutValue;


public class SelectPersonValueConvert implements IGetJoinOutValue{
    
	public String getFieldValue(Object obj, String fieldName, Object byValue) {
		if(byValue == null){
			return "";
		}
		if ("adminUserId".equals(fieldName)) { 
			 if(byValue!=null && !"".equals(byValue)){
				 try {
					 
					 return CommonUtils.getUserNameById(Long.valueOf(byValue.toString()));
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			 }
		}
		if ("sex".equals(fieldName)) { 
			 if(byValue!=null){
				 try {
					 Set<DictCode> set = SuperContext.dictCache.getCodesByName("SEX");
					 Iterator it = set.iterator();
					 while(it.hasNext()){
						 DictCode dict = (DictCode) it.next();
						 if(dict.getCodeNum().equals(byValue.toString())){
							 return dict.getCodeValue();
						 }
					 }
				}
				catch(Exception e) {
					e.printStackTrace();
				}
			 }
		}
		return byValue.toString();
	}

}
